package com.itheima03;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class<?> c = Class.forName("com.itheima02.Student");

        Constructor<?> declaredConstructor = c.getDeclaredConstructor(String.class);

        // 暴力反射
        // true：取消访问检查
        declaredConstructor.setAccessible(true);

        Object o = declaredConstructor.newInstance("另天气");
        System.out.println(o);
    }
}
